package com.the_ring.behavior.iterator;

import java.util.ArrayList;

/**
 * @author: t22306139
 * @date: 2023/12/1  14:09
 */
public class MenuIterator implements Iterator{

    private int position;
    private final ArrayList<MenuItem> menuItems;

    public MenuIterator( ArrayList<MenuItem> menuItems) {
        this.position = 0;
        this.menuItems = menuItems;
    }

    @Override
    public boolean hasNext() {
        return position < menuItems.size();
    }

    @Override
    public Object next() {
        MenuItem menuItem = menuItems.get(position);
        position++;
        return menuItem;
    }
}
